﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BillsDomain;
using System.Windows.Controls;

namespace BillsWpf
{
    public class WpfLookupList : ILookupList
    {
        private ComboBox underlyingList;

        public WpfLookupList(ComboBox underlyingList)
        {
            this.underlyingList = underlyingList;
        }


        #region ILookupList Members

        public void Add(object item)
        {
            this.underlyingList.Items.Add(item);
        }

        public void Clear()
        {
            this.underlyingList.Items.Clear();
        }

        public object SelectedItem
        {
            get
            {
                object underlyingListSelectedItem = this.underlyingList.SelectedItem;
                if (underlyingListSelectedItem == null)
                {
                    underlyingListSelectedItem = this.underlyingList.Text;
                }

                return underlyingListSelectedItem;
            }
            set { this.underlyingList.SelectedItem = value; }
        }

        #endregion
    }
}
